﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Chinaer.Core.Helper
{
    /// <summary>
    /// 异常信息显示helper
    /// </summary>
    public class ExceptionMessageHelper
    {
        private static object lockObj = new object();

        public static string RollException(Exception ex)
        {
            if (ex == null)
            {
                return "";
            }
            StringBuilder sb = new StringBuilder();
            sb.Append(ex.Message);
            lock (lockObj)
            {
                if (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                    sb.Append(ex.Message + ex.Source + ex.StackTrace);
                    RollException(ex);
                }
                return sb.ToString();
            }
        }
    }
}
